package com.orphan.util.mqConfig;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SupplierInfoMq {
    @Autowired
    CachingConnectionFactory cachingConnectionFactory;
//    @Bean(value = "rabbitTemplate")
//    public RabbitTemplate rabbitTemplate(){
//        return new RabbitTemplate(cachingConnectionFactory);
//    }
    @Bean
    public Queue queueSupplierInfo(){
        return new Queue("supplierInfo");
    }
    @Bean
    public DirectExchange directExchange(){
        return new DirectExchange("supplierExchange" );
    }
    @Bean
    public Binding QueueSupplierInfoToDirectExchange(Queue queueSupplierInfo,DirectExchange directExchange){
        return BindingBuilder.bind(queueSupplierInfo).to(directExchange).with("Register");
    }

}
